home *** CD-ROM | disk | FTP | other *** search
/ Acorn Risc Technologies StrongARM CD-ROM / Acorn Risc Technologies StrongARM CD-ROM.iso / ftp / documents / appnotes / 061_075 / 061c / Text
Encoding:
Text File  |  1993-08-02  |  10.4 KB  |  232 lines

  1. 28th October 1992
  2. -----------------------------------------------------------------------------
  3. Support Group Application Note 
  4. Number: 061
  5. Issue: 2
  6. Author:
  7. -----------------------------------------------------------------------------
  8.  
  9. Creating 6502 Applications using !65Host
  10.  
  11. -----------------------------------------------------------------------------
  12. Applicable Hardware: Archimedes range
  13.  
  14. Related Application Notes:      059 - Archimedes 6502 Emulation
  15.                                 058 - 6502 to ARM Application Note
  16.  
  17.  
  18. -----------------------------------------------------------------------------
  19. Copyright (C) Acorn Computers Limited 1992
  20.  
  21. Every effort has been made to ensure that the information in this leaflet is 
  22. true and correct at the time of printing. However, the products described in
  23. this leaflet are subject to continuous development and improvements and
  24. Acorn Computers Limited reserves the right to change its specifications at
  25. any time. Acorn Computers Limited cannot accept liability for any loss or
  26. damage arising from the use of any information or particulars in this
  27. leaflet. ACORN, ECONET and ARCHIMEDES are trademarks of Acorn Computers
  28. Limited.
  29. -----------------------------------------------------------------------------
  30. Support Group
  31. Acorn Computers Limited
  32. Acorn House
  33. Vision Park
  34. Histon
  35. Cambridge       CB4 4AE
  36. -----------------------------------------------------------------------------
  37.  
  38.  
  39. OBTAINING !65HOST
  40.  
  41. The !65Host BBC Emulator supplied on the RISC OS Extras disc has many useful
  42. features above and beyond that of the version supplied on Applications disc
  43. 2.  The RISC OS Extras disc is available from Acorn dealers.
  44.  
  45. !65Host's name comes from the 6502 microprocessor, which is at the heart of
  46. the BBC Model B.  The 'Host' part is derived from the fact that the program
  47. emulates a stand alone machine rather than a second processor add on.  It is
  48. possible using !65Host to take BBC B, B+, Master 128 or Master Compact
  49. software, and to package it up conveniently as a single RISC OS application. 
  50. That is a single icon can be created, that when double clicked on, will
  51. start the BBC emulator and enter it running a particular BBC program.  What
  52. is more, such applications once created, may be moved freely between ADFS
  53. hard discs, ADFS floppy discs, Econet or SCSIFS.
  54.  
  55.  
  56. A LITTLE BACKGROUND INFORMATION
  57.  
  58. In order to fully understand how to create "6502 application" it will be
  59. necessary to discuss a little of how the RISC OS desktop works.
  60.  
  61. To create an application, first create a directory but begin its name with
  62. the ! (pronounced pling) character.  Instead of the light blue folder icon,
  63. it will be given the default application icon (an Archimedes logo with the
  64. word APP in its top left corner).
  65.  
  66. When you double click on a directory, a window called a directory viewer
  67. will open to show its contents.  In order to show an applications contents
  68. the shift key should be held down when double clicking, and the application
  69. will open just as a directory does.  If you try this on the application
  70. supplied with RISC OS such as !Paint, !Edit, !Draw and !65Host you will see
  71. they contain several files.  Sometimes you will see that an application has
  72. subdirectories inside itself.
  73.  
  74. When you first open a directory viewer RISC OS "sees" the applications it
  75. contains.  If the application has not been "seen" before then RISC OS looks
  76. inside the application for a file called !Boot and if it finds one it
  77. executes it.  The job of a !Boot file is to let RISC OS know where the
  78. application is and what it can do.  For example !Draw's boot file lets RISC
  79. OS know that there is an application, !Draw, that can be run and passed a
  80. Draw file if it is double clicked on.
  81.  
  82. !65Host's !Boot file is very simple and just sets up a system variable that
  83. is the full path name of !65Host.  A system variable is just like a string
  84. variable in BASIC.  To use the contents of a system variable refer to it by
  85. its name enclosed in angle brackets.  !65Host's !Boot file sets up a
  86. variable called <65Host$Dir>.  For instance you can use this variable to
  87. view the contents of !65Host by typing *CAT <65Host$Dir>.
  88.  
  89. When you double click on an application RISC OS looks for a file inside the
  90. application called !Run.  If one is not found you will actually receive an
  91. error message.  For this reason alone all applications should contain a !Run
  92. file.  The job of the !Run file is to kick off the actual process that leads
  93. to the application running.  This might involve loading modules into memory,
  94. declaring how much memory is needed, setting system variables and so on.  It
  95. could, however, be as simple as a single * command.
  96.  
  97. The !Run file of an application is almost always a special form of command
  98. file called an Obey file.  Obey files may be created from !Edit by menuing
  99. on the !Edit icon on the icon bar and selecting Create->New Obey File.  Obey
  100. files when run, pass each of their lines to the * prompt just as if you had
  101. typed the line at the * prompt.  They also have the advantage of knowing
  102. where they are.  That is the system variable <Obey$Dir>, is the full path
  103. name of the obey file currently executing.  Comments may be added to obey
  104. files by placing a " | " character at the start of the line, and it is
  105. commonplace to see such comments.
  106.  
  107. If you now open up !65Host and drag its !Boot file onto !Edit you should see
  108. how it works.  The final line has a command that we haven't discussed yet,
  109. we will deal with its implications later.
  110.  
  111.  
  112. CREATING YOUR OWN 6502 APPLICATION
  113.  
  114. We now have enough information to create a "6502 application".  The program
  115. in question is given below and is a standard "Hello World"  style program
  116. merely designed to boost our confidence.  It prints a read "Hello World"
  117. banner and catalogues the current directory.
  118.  
  119. Format a 3.5 inch disc and copy !65Host onto it.  Double click on !65Host to
  120. start the emulator and enter the following:
  121.  
  122.         *MOUNT 0
  123.         10 MODE 7
  124.         20 PRINT CHR$ (129); CHR$ (157); CHR$ (131); CHR$ (141); "Hello World"
  125.         30 PRINT CHR$ (129); CHR$ (157); CHR$ (131); CHR$ (141); "Hello World"
  126.         40 *CAT
  127.         SAVE "HelloW"
  128.         *BUILD !Boot
  129.         0001 CHAIN "HelloW"
  130.         [Escape]
  131.         *QUIT
  132.  
  133. You should now have left the emulator and be back in the RISC OS desktop. 
  134. The directory viewer for your disc will now have icons for the two files you
  135. just created in the emulator.  Next create the directory !HelloW in the root
  136. of the disc next to !65Host.  Hold down shift and open !HelloW then create
  137. the following obey file and save it into !HelloW as !Run.
  138.  
  139.         Dir <Obey$Dir>.Program
  140.         Run <65Host$Dir>.!Run &B03 !Boot
  141.  
  142. Then create a subdirectory Program inside !HelloW, and move the two files
  143. you created under the emulator into the Program directory.
  144.  
  145. To recap you should now have...
  146.  
  147.         !65Host (Application)
  148.                                         !Run (Obey File)
  149.                                         !Boot (Command File)
  150.         !HelloW (Application)
  151.                         Program (Directory)
  152.                                         HelloW (BASIC File)
  153.  
  154. The moment of truth.  Double click on !HelloW.  The BASIC program HelloW
  155. will be run under 6502 emulation.
  156.  
  157. The bottom level of directories corresponds to the "Shift-Breakable" BBC
  158. disc, and this is where other "6502 applications" that you may create, would
  159. hold their actual programs.
  160.  
  161.  
  162. !65HOST BOOT OPTIONS
  163.  
  164. The ReadMe file inside !65Host gives the technical details of the boot
  165. option that we used in the above !Run file.  In our case we used &B03, as a
  166. !Boot option, and it is worth looking at this in a little more depth.  The
  167. hex digit 3 (bits 0-1) instructed the BBC Emulator to use the same boot
  168. action as *OPT4,3 would confer on a floppy disc, that is EXEC.  The hex
  169. digit B instructs the emulator to start up in a generic filing system called
  170. ARFS.
  171.  
  172. As we created !HelloW on an ADFS floppy disc we could have use &003 as the
  173. boot option and entered the default filing system, ADFS.  Or &803 could have
  174. been used, specifying ADFS directly.  However, this would mean that the
  175. !HelloW application, if copied to a network directory, would no longer
  176. function.  It is for this reason that we specified ARFS.  As RISC OS makes
  177. its filing systems appear very similar we can specify ARFS and in effect say
  178. 'I don't care which filing system we enter'.  This confers filing system
  179. portability on any "6502 application" created in this manner.
  180.  
  181.  
  182. GIVING YOUR APPLICATION ITS OWN ICON
  183.  
  184. Now we have created our portable application, we will most probably want to
  185. give it its own unique icon, so it may be distinguished.  This is easily
  186. done from !Paint.
  187.  
  188. Start !Paint and click on its icon to create a new sprite file.  Menu on the
  189. empty browser window and select "create".  The name of the sprite should be
  190. the same as that of our application "!HelloW".  The sprite should also have
  191. width of 34, a height of 17 and be in mode 12.  These settings are standard
  192. that must be adhered to.  Now use !Paint to design your sprite and when you
  193. have finished save it into !HelloW as a file called "!Sprites".
  194.  
  195. Now when you application is 'seen' on the Desktop your sprite will be used
  196. for its icon.  RISC OS does this automatically, however, to be absolutely
  197. correct we should create a !Boot file for our application that contains the
  198. line:
  199.  
  200.         Iconsprites <Obey$Dir>.!Sprites
  201.  
  202.  
  203. SOME FURTHER IDEAS
  204.  
  205. If you intend to use your 6502 applications on a network then it is probably
  206. a good idea to create the applications as indicated so far.  This means that
  207. each user should have a copy of !65Host in their directory.  Alternatively,
  208. a single copy of !65Host may be referenced by the !Armboot file in each
  209. users directory.  For example if !65Host were placed in the directory $.Apps
  210. you may use a line such as this:
  211.  
  212.         Run $.Apps.!65Host.!Boot
  213.  
  214.  
  215. You must ensure that all the files that comprise !65Host are given public
  216. read access.  This approach could potentially save 100K per user.
  217.  
  218. Another approach that may be attractive is to 'hide' !65Host inside your
  219. 6502 Application, next to your !Run file.  This has two benefits:
  220.  
  221.         a)  Everything needed by the application is contained within it, and
  222.         it may be easily copied from disc to disc.
  223.  
  224.         b)  It may be less confusing for some users, as they need only to
  225.         see a single icon.
  226.  
  227. You may like to add a function key definition that quits the 6502 emulator
  228. and return the user to the desktop.  For example we could have added an
  229. extra line to our !HelloW application's !Boot file to set key F1 to quit:
  230.  
  231.         *KEY1 *QUIT |M
  232.         CHAIN "HelloW"